package com.ymttest.database.sqlwapper.hunter;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.ymt.database.SqlManager;
import com.ymttest.database.model.hunter.HunterAncestry;

public class HunterAncestryWrapper {
	
	SqlManager manager;

    public HunterAncestryWrapper() {
        manager = new SqlManager("hunter");
    }
    
    @SuppressWarnings("unchecked")
	public HunterAncestry selectByPrimaryKey(Long id) {
    	
    	HunterAncestry hunterAncestry = new HunterAncestry();
    	List<HunterAncestry> result = manager
                .getSelectResults(
                        "com.ymttest.database.mapping.hunter.HunterAncestryMapper.selectByPrimaryKey",
                        id);
        manager.commit();
        
		if (result.size() > 0) {
			hunterAncestry = result.get(0);
		}
		
        return hunterAncestry;
    }
    
    @SuppressWarnings({ "unchecked", "rawtypes" })
	public HunterAncestry selectByHunterIdAndOrderId(Long hunterId, Long orderId) {
    	
    	HunterAncestry hunterAncestry = new HunterAncestry();
    	Map m = new HashMap<String, String>();
    	
		m.put("hunterId", hunterId);
		m.put("orderId", orderId);

    	List<HunterAncestry> result = manager
                .getSelectResults(
                        "com.ymttest.database.mapping.hunter.HunterAncestryMapper.selectByHunterIdAndOrderId",
                        m);
        manager.commit();
        
		if (result.size() > 0) {
			hunterAncestry = result.get(0);
		}
		
        return hunterAncestry;
    }
    
    public static void main(String[] args) {
    	HunterAncestryWrapper wrapper = new HunterAncestryWrapper();
    	System.out.println(wrapper.selectByHunterIdAndOrderId(4321L, 1380040246L).getHunter_level());
    }
}
